//
//  ViewController.m
//  06-UINavigation
//
//  Created by dllo on 16/7/21.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "ViewController.h"
#import "NextViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//    self.navigationItem.title = @"你是小王八";
    // 该层title是push层leftBarButtonItem的title
    self.title = @"AA";
    

    // 标题视图放上去,标题就消失,标题视图修改不了x,y
    UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:@[@"红",@"黄",@"绿"]];
    seg.frame = CGRectMake(0, 0, 300, 44);
    self.navigationItem.titleView = seg;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(back:)];
    // 隐藏
    self.navigationController.navigationBarHidden = NO;
    // 名义上背景(朦胧)
//    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    // 实质上背景bartinkColor()
    self.navigationController.navigationBar.barTintColor = [UIColor grayColor];
    // 元素颜色tintColor
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    // 透明度,yes 从(0,0)开始,no 从(64,0)开始
    self.navigationController.navigationBar.translucent = NO;
    UIButton *bu = [UIButton buttonWithType:UIButtonTypeCustom];
    bu.backgroundColor = [UIColor yellowColor];
    bu.frame = CGRectMake(0, 0, 100, 50);
    bu.layer.cornerRadius = 10;
    bu.layer.masksToBounds = YES;
    [self.view addSubview:bu];
    [bu addTarget:self action:@selector(push) forControlEvents:UIControlEventTouchUpInside];
    // 改变坐标的效果,与translucent效果一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
    // 栈的子类
    NSLog(@"自控制器\n%@",self.navigationController.viewControllers);
    // 最后进入
    NSLog(@"当前控制器%@",self.navigationController.visibleViewController);
   }
- (void)push {
    [self.navigationController pushViewController:[[NextViewController alloc] init] animated:YES];
}
- (void)back:(UIBarButtonItem *)ba {
    NSLog(@"等等");
    // 页面跳转
    // navigationController 有两个uiviewcontroller
    [self.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
